package com.youwatch.concurrency.example.singleton;

import com.youwatch.concurrency.annotations.NotThreadSafe;

/**
 * @Author: kss
 * @Description: 单例-懒汉模式
 * @Date: Create in 2019/1/17
 */
@NotThreadSafe
public class SingletonLazybonesUnsafe {

    // 构造方法私有化
    private SingletonLazybonesUnsafe() {
        // 很多运算操作...初始化多次可能会出错
    }

    // 单例对象
    private static SingletonLazybonesUnsafe instance = null;

    // 静态工厂方法
    public static SingletonLazybonesUnsafe getInstance() {
        if (instance == null) {
            instance = new SingletonLazybonesUnsafe();
        }
        return instance;
    }

}
